<%@ Page Title="Member_Recharge Item" Language="C#" AutoEventWireup="true" CodeBehind="Member_RechargeItem.aspx.cs" Inherits="Youz.CreditRepay.Manage.Member_RechargeItem" %>

<script>
    

    var requireJS = [
        //"assets/js/jquery.form.js"
    ];
    loadJS(requireJS);
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-edit"></i><%: R(LanguageModule.Member_Recharge, "Member_Recharge", "Member_Recharge") %></h2>
            </div>
            <div class="panel-body">
                <form id="frm" class="form-horizontal" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "RechargeID", "充值单号") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="RechargeID" name="RechargeID" maxlength="50" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "MemberAccount", "会员帐号") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="MemberAccount" name="MemberAccount" maxlength="50" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "FromBankName", "转账银行名称") %> </label>
                                <div class="col-md-9">
                                    <input type="text" id="FromBankName" name="FromBankName" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "ToBankName", "收款银行名称") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="ToBankName" name="ToBankName" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "FromBankAccountNo", "转账银行账户号") %> </label>
                                <div class="col-md-9">
                                    <input type="text" id="FromBankAccountNo" name="FromBankAccountNo" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "ToBankAccountNo", "收款银行账户号") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="ToBankAccountNo" name="ToBankAccountNo" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "FromBankAccountName", "转账银行賬戶名") %> </label>
                                <div class="col-md-9">
                                    <input type="text" id="FromBankAccountName" name="FromBankAccountName" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "ToBankAccountName", "收款银行賬戶名") %> </label>
                                <div class="col-md-9">
                                    <input type="text" id="ToBankAccountName" name="ToBankAccountName" maxlength="200" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "FromAmount", "充值金额") %></label>
                                <div class="col-md-9">
                                    <input type="text" style="font-size: 24px; color: #f86c6b" id="FromAmount" name="FromAmount" maxlength="9" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "ToAmount", "实际金额") %></label>
                                <div class="col-md-9">
                                    <input type="text" style="font-size: 24px; color: #f86c6b" id="ToAmount" name="ToAmount" maxlength="9" class="form-control" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "MoneyType", "币种") %></label>
                                <div class="col-md-9">
                                    <%--<input type="text" id="MoneyType" name="MoneyType" maxlength="40" class="form-control" readonly="readonly" />--%>
                                    <select id="MoneyType" name="MoneyType" class="form-control" disabled="disabled">
                                        <option value="">选择充值币种</option>
                                        <% List<Sys_Currency> Currencylist = new Sys_CurrencyBLL().GetCurrency();
                                           foreach (var item in Currencylist)
                                           {
                                        %>
                                        <option style="padding: 5px" value="<%: item.CurrencyID.ToString() %>"><%: item.CurrencyName.ToString() %></option>
                                        <%  
                                           }
                                        %>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "TransferTime", "转账时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="TransferTime" name="TransferTime" maxlength="20" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "CreateTime", "创建时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="CreateTime" name="CreateTime" maxlength="20" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "ModifyTime", "修改时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="ModifyTime" name="ModifyTime" maxlength="20" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "Status", "状态") %></label>
                                <div class="col-md-9">
                                    <%--<input type="text" id="Status" name="Status" maxlength="4" class="form-control" readonly="readonly" />--%>
                                    <select name="Status" id="Status" class="form-control" disabled="disabled">
                                        <option value=""><%: R(LanguageModule.M_Common, "All", "全部") %></option>
                                        <option value="0"><%: R(LanguageModule.Member_Recharge, "Pending", "待汇款") %></option>
                                        <option value="1"><%: R(LanguageModule.Member_Recharge, "Untreated", "未处理") %></option>
                                        <option value="2"><%: R(LanguageModule.Member_Recharge, "Processing", "处理中") %></option>
                                        <option value="3"><%: R(LanguageModule.Member_Recharge, "Ratify", "批准申请") %></option>
                                        <option value="4"><%: R(LanguageModule.Member_Recharge, "Refuse", "拒绝申请") %></option>
                                        <option value="5"><%: R(LanguageModule.Member_Recharge, "Revoked", "已撤消") %></option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "Memo", "备注") %> </label>
                                <div class="col-md-9">
                                    <input type="text" id="Memo" name="Memo" maxlength="1000" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "Accessory", "附件（汇款凭证）") %></label>
                                <div class="col-md-9">
                                    <img id="Accessory" class="img-thumbnail col-sm-2" src="../assets/img/DefaultImg.jpg" alt="Sample Image" />
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"></label>
                                <div class="col-md-9">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="RoleDesc"><%: R(LanguageModule.Member_Recharge, "AuditOpinion", "审核意见") %></label>
                                <div class="col-md-9">
                                    <textarea id="AuditOpinion" name="AuditOpinion" rows="2" maxlength="1000" class="form-control"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Recharge, "AuditTime", "审核时间") %></label>
                                <div class="col-md-9">
                                    <input type="text" id="AuditTime" name="AuditTime" maxlength="100" class="form-control" readonly="readonly" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="alert alert-danger" style="display: none;">
                        <button type="button" class="close" data-dismiss="alert">×</button><strong>提示信息：</strong><span class="content"></span>
                    </div>
                    <div class="row">
                        <div class="col-md-6">
                            <label class="col-md-3 control-label"></label>
                            <div class="form-actions">
                                <div class="col-md-9">
                                    <button class="btn btn-primary" type="button" id="Processing" name="Processing"><%: R(LanguageModule.M_Common, "Review", "审核中") %></button>
                                    <button class="btn btn-success" type="button" id="AuditNotPass" name="AuditNotPass"><%: R(LanguageModule.M_Common, "AuditNotPass", "拒 絕") %></button>
                                    <button class="btn btn-success" type="button" id="AuditBy" name="AuditBy"><%: R(LanguageModule.M_Common, "AuditBy", "同 意") %></button>
                                    <button class="btn btn-default" type="button" id="btnCancel"><%: R(LanguageModule.M_Common, "btnCancel", "取消") %></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="modalImg">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">汇款凭证</h4>
            </div>
            <div class="modal-body">
                <img id="img" class="img-responsive" src="" />
            </div>
            <div class="modal-footer">
                <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    var flag = false;

    //function validate() {
    //    return $("#frm").valid();
    //};

    function get() {
        var RechargeID = "<%: WebHelper.Get("RechargeID") %>";
        var View = "<%: WebHelper.Get("View") %>";
        if (View == 1) {
            $("#AuditOpinion").attr("disabled", "disabled");
            $("#Processing").hide();
            $("#AuditNotPass").hide();
            $("#AuditBy").hide();
        }

        //绑定数据
        $.post("Member/Handlers/Member_RechargeHandler.ashx?type=getRate", { RechargeID: RechargeID }, function (data) {
            $('#frm').fill(data[0]);
            $("#ToAmount").val((data[0].FromAmount * data[0].Rate).toFixed(2));
            $("#Status").attr("value", data[0].Status);
            $("#MoneyType").attr("value", data[0].MoneyType);
            $("#Accessory").attr("src", data[0].Accessory);
            $("#img").attr("src", data[0].Accessory);
            if (data[0].Status == 2) {
                $("#Processing").hide();
            }
            if (data[0].Accessory == "") {
                $("#Accessory").attr("src", "../assets/img/DefaultImg.jpg");
                $("#img").attr("src", "../assets/img/DefaultImg.jpg");
            }
        }, 'json');

        //审核信息
        var RecordTable = 'Member_Recharge';
        var RecordType = 'Status';
        var ObjectID = RechargeID;
        $.post("Sys/Handlers/Sys_StatusRecordHandler.ashx?type=getAuditRecord", { RecordTable: RecordTable, RecordType: RecordType, ObjectID: ObjectID }, function (data) {
            if (data != null) {
                $("#AuditTime").val(data.CreateTime);
                $("#AuditOpinion").val(data.Memo);
            }
        }, 'json');
    }

    $(function () {
        //$("#frm").validate({
        //    errorElement: "span"
        //});

        get();

        //$("#frm").ajaxForm({
        //    dataType: 'json',
        //    beforeSubmit: function (arr, $form, options) {
        //        if (flag) {
        //            return false;
        //        }
        //        else {
        //            flag = true;
        //            return true;
        //        }
        //    },
        //    success: function (data) {
        //        if (data.isSuccess) {
        //            loadPage("Member/Member_RechargeList.aspx");
        //        }
        //        else {
        //            $(".alert > .content").html(data.message);
        //            $(".alert").show();
        //        }
        //        flag = false;
        //    }
        //});

        //處理中
        $("#Processing").click(function () {
        $('#confirm .btn-primary').unbind('click');
            AuditHandle(2);
        });

        //拒 絕(0待汇款、1未处理、2处理中、3批准申请、4拒绝申请、5已撤消)
        $("#AuditNotPass").click(function () {
        $('#confirm .btn-primary').unbind('click');
            if ($("#AuditOpinion").val() == "") {
                $(".alert > .content").html("审核意见不能为空！");
                $(".alert").show();
                return false;
            }
            jconfirm("你确定要拒绝此记录吗？", function () {
                AuditHandle(4);
            })
        });
        //同 意
        $("#AuditBy").click(function () {
        $('#confirm .btn-primary').unbind('click');
            jconfirm("你确定要同意此记录吗？", function () {
                AuditHandle(3);
            })
        });

        function AuditHandle(Status) {
            var AuditOpinion = $("#AuditOpinion").val();
            var ToAmount = $("#ToAmount").val();
            if (!(/^(0|[1-9][0-9]*)(\.\d{1,2})?$/.test(ToAmount)) || ToAmount <= 0) {
                $(".alert > .content").html("实际到账金额只能为带两位小数的正数！");
                $(".alert").show();
                return false;
            }
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "Member/Handlers/Member_RechargeHandler.ashx?type=Audit",
                data: { RechargeID: "<%= WebHelper.Get("RechargeID") %>", ToAmount: ToAmount, AuditOpinion: AuditOpinion, Status: Status },
                success: function (data) {
                    if (data.isSuccess) {
                        loadPage("Member/Member_RechargeList.aspx");
                    }
                    else {
                        $(".alert > .content").html(data.message);
                        $(".alert").show();
                    }
                },
                error: function (message) {
                    $(".alert > .content").html("系统异常，请稍后再试");
                    $(".alert").show();
                }
            });
        }

        $("#btnCancel").click(function () {
            loadPage("Member/Member_RechargeList.aspx");
        });


        $("#Accessory").click(function () {
            //$("#img").attr("src", "../assets/img/DefaultImg.jpg");
            $("#modalImg").modal("show");
        });

    });

</script>
